//
//  BBDNavigationViewController.m
//  棒棒哒
//
//  Created by rimi on 15/8/3.
//  Copyright (c) 2015年 rimi. All rights reserved.
//

#import "BBDNavigationViewController.h"
#import "BBDTabbarViewController.h"
#import "Config.h"

@interface BBDNavigationViewController ()

@end

@implementation BBDNavigationViewController

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
    self = [super initWithRootViewController:rootViewController];
    if (self) {
        self.navigationBar.barTintColor = NAVCOLOR;
        self.navigationBar.tintColor = [UIColor whiteColor];
        self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:15]};
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //得到当前navigation栈中的第一个viewcontroller
    UIViewController *VC = self.viewControllers[0];
    //取消返回按钮的文字
    VC.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    //配置个人中心按钮
    UIBarButtonItem *profleButton = [[UIBarButtonItem alloc]initWithImage:IMAGNAME(@"个人中心.png") style:UIBarButtonItemStylePlain target:self action:@selector(profleButtonTaped:)];
    VC.navigationItem.leftBarButtonItem = profleButton;
    
}

- (void)profleButtonTaped:(UIBarButtonItem *)sender
{
    CGPoint tabBarCenter = [BBDTabbarViewController shareTabBarController].view.center;
    if (tabBarCenter.x == SCREEN_WIDTH / 2) {
        [[BBDTabbarViewController shareTabBarController]tabBarMoveToSide];
    }else {
        [[BBDTabbarViewController shareTabBarController]tabBarMoveToCenter];
    }
}

@end
